<template>
<div class="two-table">
  <el-table
    :data="tableData"
    border
    style="width: 100%">
    <el-table-column
      fixed
      prop="date"
      label="日期"
      align="center"
      width="150">
    </el-table-column>
    <el-table-column
      prop="name"
      label="姓名"
      align="center"
      width="120">
    </el-table-column>
    <el-table-column
      prop="province"
      label="省份"
      align="center"
      width="120">
    </el-table-column>
    <el-table-column
      prop="city"
      label="市区"
      align="center"
      width="120">
    </el-table-column>
    <el-table-column
      prop="address"
      label="地址"
      align="center"
      width="300">
    </el-table-column>
    <el-table-column
      prop="zip"
      label="邮编"
      align="center"
      width="120">
    </el-table-column>
     <el-table-column label="操作"  align="center">
      <template slot-scope="scope">
        <el-button
          size="mini"
          @click="handleEdit(scope.$index, scope.row)" type="text" >编辑</el-button>
        <el-button
          size="mini"
          type="danger"
          @click="handleDelete(scope.$index, tableData)">删除</el-button>
      </template>
    </el-table-column>
  </el-table>
    
    </div>
</div>
</template>

<script>
  export default {
   methods:{
      handleEdit(index,row){
        console.log(index,row);
        $("#editBox").modal();
        this.editId=index;
        this.initialData=this.tableData[index].date
      },
      save(){
        this.tableData[this.editId].date=this.initialData
      },
      handleDelete(index,data){
        //console.log(index,row);
        data.splice(index, 1);
      },
       handleEdit: function (index, row) {
				this.editFormVisible = true;
				this.editForm = Object.assign({}, row);
			} 
    },
    
    data() {
      return {
        tableData: [{
          date: '2016-05-03',
          name: '王小虎',
          province: '上海',
          city: '普陀区',
          address: '上海市普陀区金沙江路 1518 弄',
          zip: 200333
        }, {
          date: '2016-05-02',
          name: '王小虎',
          province: '上海',
          city: '普陀区',
          address: '上海市普陀区金沙江路 1518 弄',
          zip: 200333
        }, {
          date: '2016-05-04',
          name: '王小虎',
          province: '上海',
          city: '普陀区',
          address: '上海市普陀区金沙江路 1518 弄',
          zip: 200333
        }, {
          date: '2016-05-01',
          name: '王小虎',
          province: '上海',
          city: '普陀区',
          address: '上海市普陀区金沙江路 1518 弄',
          zip: 200333
        }],
         initialData:"",
        editId:0
      }
    }
  }
</script>


<style scoped lang="scss">
.two-table {
  display: flex;
  justify-content: flex-start;
  flex-wrap: wrap;
  margin-top: 50px
}
</style>


